<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/css/common.css" />
		<link rel="stylesheet" type="text/css" href="/js/flatpickr.min.css" />
		<link rel="stylesheet" type="text/css" href="/bootstrap-3.3.7/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="/dialog/css/dialog.css" />
		<link rel="stylesheet" type="text/css" href="/css/font-awesome.css" />
	</head>

	<body>
		<!--顶部导航 -->
		<nav class="topNavItemBox">
			<div id="ItemBox">
				<div class="title">肉品溯源管理系统</div>
			</div>
		</nav>
		<!-- 左侧导航 -->
		<#include "left.ftl"/>


        <div class="page_main">
			<h3>猪肉溯源管理</h3>
			<br />
			<div class="page_content">
				<h4>猪肉溯源查询</h4>
				<br />
				<form id="traceability_query" method="post" action="TraceAction_getTraceInfor">
					<label class="labelBeforinput">产品编号</label><input type="text" name="productid" class="commonInputtext" style="margin-left: 200px;" />

					<input type="submit" value="查询" style="display: inline-block; margin-left: 20px;" /> <br />
				</form>
				<div class="traceability">
					<div class="traceability_left">
						<ul>
							<li><label>产品编号</label><span>333</span></li>
							<li><label>123</label><span></span></li>
							<li><label>123</label><span></span></li>
							<li><label>123</label><span></span></li>
							<li><label>123</label><span></span></li>
							<li><label>123</label><span></span></li>
							<li><label>123</label><span></span></li>
							<li><label>123</label><span></span></li>
							<li><label>123</label><span></span></li>
							<li><label>123</label><span></span></li>
							<li><label>123</label><span></span></li>
							<li><label>123</label><span></span></li>
						</ul>
					</div>
					<div class="traceability_right">
						<ul>
							<li><input type="button" id="button1" value="养殖管理溯源" /></li>
							<li><input type="button" id="button2" value="屠宰信息溯源" /></li>
							<li><input type="button" id="button3" value="检疫信息溯源 " /></li>
							<li><input type="button" id="button4" value="防疫信息溯源" /></li>
							<li><input type="button" id="button5" value="销售信息溯源" /></li>
							<li><input type="button" id="button6" value="物流信息溯源 " /></li>
						</ul>

					</div>
				</div>
			</div>
			<div class="footer">
				<div class="footer_lineone">
					<span id="logo"></span>肉品溯源管理系统 
					<span class="footer_lineoneSpan"><a href="aboutus.html">关于我们</a></span>
					<span class="footer_lineoneSpan"><a target="_blank" href="http://www.cfsiw.com/">食品安全信息</a></span> 
					<span class="footer_lineoneSpan"><a href="suggestionAdd.ftl">联系我们</a></span>
				</div>
				<div class="footer_linetwo">
					 &copy;2017广东技术师范学院
				</div>
			</div>
		</div>

		<script src="/js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/jquery.form.js"></script>
		<script src="/js/google-maps.js" type="text/javascript" charset="utf-8"></script>
		<script src="/dialog/js/dialog.js"></script>
		<script src="/js/flatpickr.js"></script>
		<script>
			$(function() {
				$(".vertical-nav").verticalnav({
					speed: 400,
					align: "left"
				});

				var re_data; //每次传过来的数据

				$("#traceability_query").ajaxForm(function(data) {
					$(".traceability").css("display","block");
					console.log(data[0].productID);
					//console.log($(".traceability_left ul li").eq(0).find("span").text());
					$(".traceability_left ul li").eq(0).find("span").text(data[0].productID);
					
					re_data = data;
					
				});
				
				
				
				
				$("#button1").click(function(){
					$.ajax({
						type:"post",
						url:"TraceAction_getFeedingTrace",
						data: {productid:re_data[0].productID},
						success:function(data){
							console.log(data[0]);
							$(".traceability_left").find("ul").remove();
							var row_head = "<ul>";
							var row1 = "<li><label>产品编号</label><span>"+data[0].productID+"</span></li>";
							var row2 = "<li><label>生猪编号</label><span>"+data[0].animalID+"</span></li>";
							var row3 = "<li><label>养殖场</label><span>"+data[0].compName+"</span></li>";
							var row4 = "<li><label>地址</label><span>"+data[0].regAddr+"</span></li>";
							var row5 = "<li><label>养殖时间</label><span>"+data[0].age+"</span></li>";
							if(data[0].inTime){
								var row6 = "<li><label>入场时间</label><span>"+data[0].inTime.slice(0,10)+"</span></li>";
							}else{
								var row6 = "<li><label>入场时间</label><span> 暂无数据 </span></li>";
							}
							if(data[0].outTime!=null){
								var row7 = "<li><label>出场时间</label><span>"+data[0].outTime.slice(0,10)+"</span></li>";
							}else{
								var row7 = "<li><label>出场时间</label><span> 暂无数据 </span></li>";
							}
							var row8 = "<li><label>出场重量</label><span>"+data[0].outWeight+"</span></li>";
							var row9 = "<li><label>单位</label><span>"+data[0].weightUnit+"</span></li>";
							var row10 = "<li><label>主要饲料</label><span>"+data[0].purcForage+"</span></li>";
							
							var row_end = "</ul>";
							var str = row_head + row1 + row2 + row3 +row4 +row5 + row6 + row7 + row8 + row9 +row10 +row_end;

							$(".traceability_left").html(str);
						}
					});
				});
			/* ---------------------------	 */
				$("#button2").click(function(){
					$.ajax({
						type:"post",
						url:"TraceAction_getslaughterTrace",
						data: {productid:re_data[0].productID},
						success:function(data){
							$(".traceability_left").find("ul").remove();
							var row_head = "<ul>";
							var row1 = "<li><label>产品编号</label><span>"+data[0].productID+"</span></li>";
							var row2 = "<li><label>生猪编号</label><span>"+data[0].animalID+"</span></li>";
							var row3 = "<li><label>屠宰场</label><span>"+data[0].compName+"</span></li>";
							if(data[0].slaughterTime!=null){
								var row4 = "<li><label>屠宰时间</label><span>"+data[0].slaughterTime.slice(0,10)+"</span></li>";
							}else{
								var row4 = "<li><label>屠宰时间</label><span>暂无数据</span></li>";
							}
							var row5 = "<li><label>流水线</label><span>"+data[0].procLineName+"</span></li>";
							var row6 = "<li><label>屠宰地址</label><span>"+data[0].regAddr+"</span></li>";
							var row7 = "<li><label>屠宰许可证</label><span>"+data[0].slaughterPermitNo+"</span></li>";

							
							var row_end = "</ul>";
							var str = row_head + row1 + row2 + row3 +row4 +row5 + row6 + row7 +row_end;

							$(".traceability_left").html(str);
						}
					});
				});
				
				$("#button3").click(function(){
					$.ajax({
						type:"post",
						url:"TraceAction_getInspectTrace",
						data: {productid:re_data[0].productID},
						success:function(data){
							$(".traceability_left").find("ul").remove();
							var row_head = "<ul>";
							var row1 = "<li><label>产品编号</label><span>"+data[0].productID+"</span></li>";
							var row2 = "<li><label>生猪编号</label><span>"+data[0].animalID+"</span></li>";
							var row3 = "<li><label>检疫单位</label><span>"+data[0].compName+"</span></li>";
							var row4 = "<li><label>检疫类型</label><span>"+data[0].inspectType+"</span></li>";
							if(data[0].inspectTime!=null){
							var row5 = "<li><label>检疫时间</label><span>"+data[0].inspectTime.slice(0,10)+"</span></li>";
							}else{
							var row5 = "<li><label>检疫时间</label><span>暂无数据</span></li>";
							}
							var row6 = "<li><label>检疫次数</label><span>"+data[0].inspectTimes+"</span></li>";
							var row7 = "<li><label>检疫部位</label><span>"+data[0].inspectPosition+"</span></li>";
							
							var row_end = "</ul>";
							var str = row_head + row1 + row2 + row3 +row4 +row5 + row6 +row7 +row_end;

							$(".traceability_left").html(str);
						}
					});
				});
				
				
				
				$("#button4").click(function(){
					$.ajax({
						type:"post",
						url:"TraceAction_getantiepidemicTrace",
						data: {productid:re_data[0].productID},
						success:function(data){
						console.log(data);
						var strAll;
						for(i =0 ;i<data.length;i++){
							$(".traceability_left").find("ul").remove();
							var row_head = "<ul>";
							var row1 = "<li><label>产品编号</label><span>"+data[i].productID+"</span></li>";
							var row2 = "<li><label>生猪编号</label><span>"+data[i].animalID+"</span></li>";
							var row3 = "<li><label>防疫公司</label><span>"+data[i].compName+"</span></li>";
							if(data[i].epidDate!=null){
								var row4 = "<li><label>防疫时间</label><span>"+data[i].epidDate.slice(0,10)+"</span></li>";
							}else{
							var row4 = "<li><label>防疫时间</label><span>暂无数据</span></li>";
							}
							var row5 = "<li><label>疫苗名称</label><span>"+data[i].vaccineName+"</span></li>";
							var row6 = "<li><label>疫苗类型</label><span>"+data[i].vaccineType+"</span></li>";
							var row7 = "<li><label>疫苗剂量</label><span>"+data[i].amount+"</span></li>";
							var row8 = "<li><label>剂量单位</label><span>"+data[i].unit+"</span></li>";
							var row_end = "</ul>";
							var str = row_head + row1 + row2 + row3 +row4 +row5 + row6 +row7 +row8 +row_end;
							strAll = strAll+ str;
							console.log(strAll);
							$(".traceability_left").html(strAll.slice(9,strAll.length-1));
							}
						}
					});
				});
				
				$("#button5").click(function(){
					$.ajax({
						type:"post",
						url:"TraceAction_getsalecTrace",
						data: {productid:re_data[0].productID},
						success:function(data){
							$(".traceability_left").find("ul").remove();
							var row_head = "<ul>";
							var row1 = "<li><label>产品编号</label><span>"+data[0].productID+"</span></li>";
							var row2 = "<li><label>生猪编号</label><span>"+data[0].animalID+"</span></li>";
							var row3 = "<li><label>销售商名称</label><span>"+data[0].salerName+"</span></li>";
							if(data[0].inTime!=null){
								var row4 = "<li><label>入库时间</label><span>"+data[0].inTime.slice(0,10)+"</span></li>";
							}else{
								var row4 = "<li><label>入库时间</label><span>暂无数据</span></li>";
							}
							if(data[0].selledTime!=null){
								var row5 = "<li><label>售出时间</label><span>"+data[0].selledTime.slice(0,10)+"</span></li>";
							}else{
								var row5 = "<li><label>售出时间</label><span>暂无数据</span></li>";
							}
							var row6 = "<li><label>客户名称</label><span>"+data[0].custName+"</span></li>";
							var row7 = "<li><label>销售价格</label><span>"+data[0].procPrice+"</span></li>";
							var row8 = "<li><label>计量单位</label><span>"+data[0].procUnit+"</span></li>";
							var row9 = "<li><label>重量</label><span>"+data[0].procCount+"</span></li>";
							var row10 = "<li><label>折扣</label><span>"+data[0].procDisCount+"</span></li>";
							var row11 = "<li><label>实际售价</label><span>"+data[0].sellPrice+"</span></li>";
							var row12 = "<li><label>交付状态</label><span>"+data[0].finishState+"</span></li>";
							
							var row_end = "</ul>";
							var str = row_head + row1 + row2 + row3 +row4 +row5 + row6 +row7 +row8 + row9 +row10 +row11 + row12  +row_end;

							$(".traceability_left").html(str);
						}
					});
				});
				
				$("#button6").click(function(){
					$.ajax({
						type:"post",
						url:"TraceAction_getTransportTrace",
						data: {productid:re_data[0].productID},
						success:function(data){
							$(".traceability_left").find("ul").remove();
							var row_head = "<ul>";
							var row1 = "<li><label>产品编号</label><span>"+data[0].productID+"</span></li>";
							var row2 = "<li><label>生猪编号</label><span>"+data[0].animalID+"</span></li>";
							var row3 = "<li><label>物流公司</label><span>"+data[0].compName+"</span></li>";
							var row4 = "<li><label>物流批次</label><span>"+data[0].transitBatchID;+"</span></li>";
							if(data[0].startTime!=null){
								var row5 = "<li><label>开始时间</label><span>"+data[0].startTime.slice(0,10)+"</span></li>";
							}else{
								var row5 = "<li><label>开始时间</label><span>暂无数据</span></li>";
							}
							
							if(data[0].endTime!=null){
								var row6 = "<li><label>结束时间</label><span>"+data[0].endTime.slice(0,10)+"</span></li>";
							}else{
								var row6 = "<li><label>结束时间</label><span>暂无数据</span></li>";
							}
							var row7 = "<li><label>物流路线</label><span>"+data[0].routeName+"</span></li>";
							var row8 = "<li><label>途径站点</label><span>"+data[0].stationName+"</span></li>";
							var row_end = "</ul>"
							var str = row_head + row1 + row2 + row3 +row4 +row5 + row6 +row7 +row8 +row_end;

							$(".traceability_left").html(str);
						}
					});
				});
			});
		</script>
	</body>

</html>